package com.yazi.mxz.common.db.dao.impl;


import java.util.HashMap;
import java.util.Map;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.myframework.smhj.hibernate.dao.BasicDao;

import com.yazi.mxz.common.db.dao.SecurityQuestionDao;
import com.yazi.mxz.common.entity.beans.Member;
import com.yazi.mxz.common.entity.beans.SecurityQuestion;

@Repository("securityQuestionDao")
public class SecurityQuestionDaoImpl extends BasicDao<SecurityQuestion> implements SecurityQuestionDao {


	public SecurityQuestionDaoImpl() {
		super(SecurityQuestion.class);
		
	}

	@Override
	public Criteria getExample(SecurityQuestion sq, String searchWord) {
		Criteria c = super.getExample(sq, searchWord);
		if (null != sq) {
			// 用户
			Member member = sq.getMember();
			if (null != member) {
				// 用户ID
				if (null != member.getMemberId()) {
					c.add(Restrictions.eq("member.memberId", member.getMemberId()));
				} else {
					// ...用户其它条件
				}
			}
			// ...安全提问其它关联对象条件
		}
		// ...关键字searchWord查询条件
		return c;
	}

	@Override
	public void delByMemberId(long memberId) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("memberId", memberId);
		executeUpdate("delByMemberId", map);
	}
	
}
